package game;

import java.awt.Color;

public class MovingPlatform extends Platform {
	public static final long serialVersionUID = 1L;
	protected int moveWidth;
	protected int moveSpeed;
	protected boolean movingRight;
	protected int org;
	
	public MovingPlatform(){}
	
	public MovingPlatform(Level g, int x, int y, int w, int h, Color c, int mw, int s){
		super(g, x, y, w, h, c);
		moveWidth = mw;
		moveSpeed = s;
		movingRight = true;
		org = x;
	    xMotion = moveSpeed;
	}
	
	@Override
	public void update(){
		super.update();
		if(movingRight){
			xMotion = moveSpeed;
			x += moveSpeed;
			if(x > moveWidth + org){
				x = moveWidth + org;
				movingRight = false;
			}
		}else{
			xMotion = -moveSpeed;
			x -= moveSpeed;
			if(x < org){
				x = org;
				movingRight = true;
			}
		}
	}
}
